﻿@model ABCTile.ViewModel.CompanyIndexData

@{
    ViewBag.Title = "Index";
}


<h2>Company List</h2>

<div>
	@Html.ActionLink("Create New Company", "Create") | @Html.ActionLink("Search for a Company", "Search")
	<br /> <br />
</div>

<br />
<table>
    <tr>
		<th>
            Company Name:
        </th>
        <th>
            Branch:
        </th>
        <th>
            Contact Role:
        </th>
        <th>
            Contact Person ID:
        </th>
        <th>
            Office Phone:
        </th>
        <th>
            Office Fax:
        </th>
        <th>
            Cell Phone:
        </th>
        <th>
            Company URL:
        </th>
        <th>
            Address:
        </th>
        <th>
            Comments:
        </th>
        <th></th>
    </tr>

@if (Model.PagedCompanies != null && Model.PagedCompanies.Count > 0)
{
	foreach (var item in Model.PagedCompanies)
	{ 
        <tr>
			<td>
                @Html.DisplayFor(modelItem => item.Company_Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Branch_Seq)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact_Role)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact_Person_ID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Office_Phone)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Office_Fax)
            </td>
			<td>
				@Html.DisplayFor(modelItem => item.Cell_Phone)
			</td>
			<td>
				@{
					string url = "http://" + Html.DisplayFor(model => item.Company_url);
				}
				<a href=@url target=_blank>@Html.DisplayFor(model => item.Company_url)</a>
			</td>
			<td>
				@Html.DisplayFor(modelItem => item.Street_Address)<br />
				@Html.DisplayFor(modelItem => item.City), @Html.DisplayFor(modelItem => item.State) @Html.DisplayFor(modelItem => item.Zip)
			</td>
            <td>
                @Html.DisplayFor(modelItem => item.Comments)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.ID })
            </td>
        </tr>
        
	}

}

</table>
<div>

    Page @(Model.PagedCompanies.PageCount < Model.PagedCompanies.PageNumber ? 0 : Model.PagedCompanies.PageNumber)
    of @Model.PagedCompanies.PageCount
    &nbsp;
    @if (Model.PagedCompanies.HasPreviousPage)
	{
        @Html.ActionLink("<<", "Index", new { page = 1 })
        @Html.Raw("&nbsp;");
        @Html.ActionLink("< Prev", "Index", new { page = Model.PagedCompanies.PageNumber - 1 })
	}
	else
	{
        @: <<
    @Html.Raw("&nbsp;");
        @: < Prev
    }
    &nbsp;
    @if (Model.PagedCompanies.HasNextPage)
	{
        @Html.ActionLink("Next > ", "Index", new { page = Model.PagedCompanies.PageNumber + 1 })
        @Html.Raw("&nbsp;");
        @Html.ActionLink(">>", "Index", new { page = Model.PagedCompanies.PageCount })
	}
	else
	{
        @:Next >
        @Html.Raw("&nbsp;") 
        @:>>
    }

</div>

